/**
 * @file test_buffer.cc
 * @author 1102403684@qq.com
 * @brief 测试Buffer类功能
 * @version 0.1
 * @date 2024-10-02
 * 
 * @copyright Copyright (c) 2024
 * 
 */

#include <iostream>

#include "../common/Buffer.hpp"


int main()
{

    /*--------测试是否会扩容-----------*/
    Buffer buf;
    for(int i = 0;i<300;i++){
        std::string str = "hello world" + std::to_string(i) + "\n";
        buf.write_string(str);
    }

    while(buf.get_readable_size() > 0){
        std::string line = buf.get_line_pop();
        std::cout << line;
    }


    std::string tmp;
    tmp = buf.read_string(buf.get_readable_size());//只读取数据，而不弹出数据
    std::cout << tmp << std::endl;


    /*
    Buffer buf, buf2;
    std::string str = "hello world";
    buf.write_string(str);

    buf2.write_buffer(buf);
    
    std::string tmp;
    tmp = buf2.read_string(buf2.get_readable_size());//只读取数据，而不弹出数据

    // std::string tmp;
    // tmp = buf.read_string(buf.get_readable_size());//只读取数据，而不弹出数据

    std::cout << tmp << std::endl;
    std::cout << buf2.get_readable_size() << std::endl;
    */
    

    return 0;
}